//
//  OAExpenseslistManagerVC.m
//  OA项目
//
//  Created by innofive on 2018/4/17.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAExpenseslistManagerVC.h"
#import "MainTabBarViewController.h"
#import "MCSwitchTabControl.h"
#import "OAApprovelistCell.h"
#import "OAExpensesDetailsVC.h"
@interface OAExpenseslistVC ()

@end

@implementation OAExpenseslistVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
-(void)onLoadViewByWillAppear:(UITableView *)view
{
    view.backgroundColor = hexCOLOR(@"F1F1F1");
    view.separatorStyle = UITableViewCellSeparatorStyleNone;
}



#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 10;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 1;
}
-(MCCellInfo *)tableView:(UITableView *)tableView cellForIndexPath:(NSIndexPath *)indexPath IsHeight:(BOOL)isheight
{
    return [MCCellInfo configForCellId:cell Class:[OAAddWorklistCell class] Height:kFitH(85) TableView:tableView];
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView FooderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    return [MCHFViewInfo configForViewId:foodter Class:[OAExpenseslistFooder class] Height:kFitH(70) TableView:tableView];
}

#pragma mark 点击方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self onSelectVCForIndexPath:indexPath];
}
-(void)onSelectFooder:(UITapGestureRecognizer *)tapGestureRecognizer
{
    OAApprovelistFooder *fooderView = (OAApprovelistFooder *)[tapGestureRecognizer view];
    
    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:fooderView.section];
    
    [self onSelectVCForIndexPath:indexPath];
}


-(void)onSelectVCForIndexPath:(NSIndexPath *)indexPath
{
    id model = [self modelForIndexPath:indexPath];
    OAExpensesDetailsVC *vc = [[OAExpensesDetailsVC alloc]initWithStyle:(UITableViewStylePlain)];
    vc.title = @"报销申请单";
    [self pushToVC:vc model:model];
   
}
-(void)onClick:(UIButton *)button
{
//    OAApproveRejectedVC *vc =[OAApproveRejectedVC rejectedVCForType:button.tag==10?openVCTypeOne:openVCTypeTwo];
//
//    [self presentWindowToVC:vc IsNaV:NO Completion:^{
//
//    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end



@interface OAExpenseslist1VC()

@end

@implementation OAExpenseslist1VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
-(MCHFViewInfo *)tableView:(UITableView *)tableView FooderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    return [MCHFViewInfo configForViewId:foodter Class:[BaseTableViewHeaderFooterView class] Height:kFitH(10) TableView:tableView];
}

@end
@interface OAExpenseslist2VC()

@end
@implementation OAExpenseslist2VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView FooderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    return [MCHFViewInfo configForViewId:foodter Class:[BaseTableViewHeaderFooterView class] Height:kFitH(10) TableView:tableView];
}


@end
@interface OAExpenseslist3VC()

@end

@implementation OAExpenseslist3VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView FooderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    return [MCHFViewInfo configForViewId:foodter Class:[OAAddWorklistFooder class] Height:kFitH(35) TableView:tableView];
}
-(id)fooderViewModelForSection:(NSInteger)section
{
    return @(1);
}
@end




@interface OAExpenseslistManagerVC ()<panGestureRecognizerDelegate>
@property(nonatomic,strong)MainTabBarViewController *tabBarC;
@property(nonatomic,strong)MCSwitchTabControl *tabControl;

@end

@implementation OAExpenseslistManagerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    OAExpenseslistVC  *vc  = [[OAExpenseslistVC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc.view.backgroundColor = [UIColor yellowColor];
    
    OAExpenseslist1VC *vc1 = [[OAExpenseslist1VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc1.view.backgroundColor = [UIColor redColor];
    
    OAExpenseslist2VC *vc2 = [[OAExpenseslist2VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc1.view.backgroundColor = [UIColor redColor];
    
    OAExpenseslist3VC *vc3 = [[OAExpenseslist3VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc2.view.backgroundColor = [UIColor brownColor];
    
    
    NSArray *vcs = @[vc,vc1,vc2,vc3];
    MainTabBarViewController *tabBarC = [MainTabBarViewController new];
    tabBarC.panGestureDelegate = self;
    tabBarC.tabBar.hidden = YES;
    tabBarC.viewControllers = vcs;
    [self addChildViewController:tabBarC];
    [self.view addV:tabBarC.view];
    _tabBarC = tabBarC;
}

-(void)onLoadViewByWillAppear:(UIView *)view
{
    MCSwitchTabControl *v = [MCSwitchTabControl new];
    [v addTarget:self action:@selector(onClickChangeBtn:) forControlEvents:UIControlEventValueChanged];
    [v insertSegmentWithTitle:@"待审核" image:nil];
    [v insertSegmentWithTitle:@"已通过" image:nil];
    [v insertSegmentWithTitle:@"已驳回" image:nil];
    [v insertSegmentWithTitle:@"转办" image:nil];
    [view addV:v];
    _tabControl = v;
    WSELF(weakSelf);
    [self onMainQueueAddSub:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        v.frame = CGRectMake(0, 0, size.width,kFitH(45));
        weakSelf.tabBarC.view.frame = CGRectMake(0,kFitH(45),size.width,size.height-kFitH(45));
    }];
}

-(void)onClickChangeBtn:(MCSwitchTabControl *)button
{
    self.tabBarC.selectedIndex = button.selectedSegmentIndex;
    [button segmentLineScrollToIndex:button.selectedSegmentIndex animate:YES];
}

-(void)tabBarViewController:(MainTabBarViewController *)tabBarViewController SelectedIndex:(NSInteger)selectedIndex
{
    _tabControl.selectedSegmentIndex =selectedIndex;
    [_tabControl segmentLineScrollToIndex:selectedIndex animate:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
